﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace DMS.Models
{
    public class BannerObject
    {
        public BannerObject()
        {
            StartDate = DateTime.Now;
            EndDate = DateTime.Now.AddMonths(1);
        }

        public int BannerId { get; set; }
        public string BannerName { get; set; }
        public string BannerDescription { get; set; }
        public string BannerContent { get; set; }
        public string BannerContentDisplay { get; set; }
        /// <summary>
        /// Vi tri banner: 0: header; 1: right; 2: bottom; 3: left
        /// </summary>
        public int BannerPosition { get; set; }
        public string BannerPositionName { get; set; }

        /// <summary>
        /// Loai banner: 0: Image; 1: Flash; 2: Html
        /// </summary>
        public int BannerType { get; set; }
        public string BannerTypeName { get; set; }
        public bool BannerActive { get; set; }
        public DateTime StartDate { get; set; }
        public DateTime EndDate { get; set; }

        public bool IsActive
        {
            get
            {
                if(this.BannerActive)
                {
                    if (this.EndDate >= DateTime.Now && this.StartDate <= DateTime.Now)
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }   
                else
                {
                    return false;
                }
            }
        }
    }

    public class BannerModel
    {
        public BannerModel()
        {
            BannerType_List = new List<SelectListItem>();
            BannerPosition_List = new List<SelectListItem>();
            StartDate = DateTime.Now;
            EndDate = DateTime.Now.AddMonths(1);
            StartEndDate = StartDate.ToString("MM/dd/yyyy") + " - " + EndDate.ToString("MM/dd/yyyy");
        }

        public int BannerId { get; set; }

        [Display(Name = "Tên banner")]
        [Required(ErrorMessage = "Bạn chưa nhập tên Banner")]
        public string BannerName { get; set; }

        [Display(Name = "Mô tả")]
        public string BannerDescription { get; set; }

        [Display(Name = "Nội dung")]
        public string BannerContent { get; set; }
        /// <summary>
        /// Vi tri banner: 0: header; 1: right; 2: bottom; 3: left
        /// </summary>
        /// 
        [Display(Name = "Vị trí hiển thị")]
        public int BannerPosition { get; set; }

        /// <summary>
        /// Loai banner: 0: Image; 1: Flash; 2: Html
        /// </summary>
        /// 
        [Display(Name = "Loại Banner")]
        public int BannerType { get; set; }

        [Display(Name = "Trạng thái")]
        public bool BannerActive { get; set; }

        [Display(Name = "Ngày bắt đầu")]
        public DateTime StartDate { get; set; }

        [Display(Name = "Ngày kết thúc")]
        public DateTime EndDate { get; set; }
        public string StartEndDate { get; set; }

        public List<SelectListItem> BannerType_List { get; set; }
        public List<SelectListItem> BannerPosition_List { get; set; }
    }
}